import * as api from '@/services/ValueApprovelMgr';

const Model = {
  namespace: 'PriceManageApprove',
  state: {
    data: [],
  },
  effects: {
    *fetch({ payload, callback }, { call, put }) {
      yield put({
        type: 'save',
        payload: { data: [] },
      });
      const response = yield call(api.approvedCheckUsingGET, payload);
      if (response && response.data) {
        yield put({
          type: 'save',
          payload: response,
        });
      }

      if (callback && typeof callback === 'function' && response.code === 1) {
        callback(response.data);
      }
    },
  },
  reducers: {
    save(state, action) {
      return {
        ...state,
        data: action.payload.data,
      };
    },
  },
};
export default Model;
